import request from '@/utils/request'
const api = 'partyConference/'
import form from '@/utils/form'
// post指标
export function postIndicator({ id, period, conferenceType, companyCode, requireHours, requireTimes, start, end, title, description, isDefault }) {
  const allowOverWrite = true
  return request.post(`${api}IndicatorInfo`, {
    data: {
      id, period, conferenceType, companyCode, requireHours, requireTimes, start, end, title, description, isDefault
    },
    allowOverWrite
  })
}

/*
*获取指标列表
*get
*/
export function getIndicatorList({ period, conferenceType, companyCode, requireHours, requireTimes, page }) {
  return request.post(`${api}IndicatorList`, {
    period: form.toQueryStartEnd(period),
    requireHours, requireTimes, company: form.toQueryValue(companyCode),
    conferenceType: form.toQueryValue(conferenceType),
    page
  })
}

/*
*删除指标
*post
*/
export function deleteIndicator(id, companyCode) {
  const isRemoved = true
  return request.post(`${api}IndicatorInfo`, {
    data: {
      id, isRemoved, companyCode
    }
  })
}

// 查询单位的指标落实情况
export function IndicatorCompanyStatus({ company, indicator, pageIndex, pageSize }) {
  return request.get(`${api}IndicatorCompanyStatus`, {
    params: {
      company, indicator, pageIndex, pageSize
    }
  })
}

// 查询单位的会议召开情况
export function getConferenceStatistics({ period, round, company, conferenceType, start, end }) {
  return request.post(`${api}ConferenceStatistics`, {
    create: {
      start, end
    },
    period, round, company, conferenceType
  })
}

// 用户落实情况查询
export function getIndicatorUserStatus({ company, indicator, includeChildren }) {
  return request.get(`${api}IndicatorUserStatus`, {
    params: {
      company, indicator, includeChildren
    }
  })
}

// 获取单位的指标完成度
export function getIndicatorRate({ company, indicator, roundStart, roundEnd }) {
  return request.get(`${api}indicatorRate`, {
    params: {
      company, indicator, roundStart, roundEnd
    }
  })
}
